package com.dingreading.cloud.mall.controller;

import com.dingreading.cloud.common.base.R;
import com.dingreading.cloud.mall.entity.CouponStaff;
import com.dingreading.cloud.mall.entity.WebImage;
import com.dingreading.cloud.mall.service.CouponStaffService;
import com.dingreading.cloud.mall.service.WebImageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/front/mall")
@Api(tags = "商城-商城相关管理")
public class FrontMallController {

    @Resource
    private WebImageService webImageService;
    @Resource
    private CouponStaffService couponStaffService;


    @ApiOperation(value = "获取商城轮播图")
    @PostMapping(value = "/getBanner")
    public R<Object> getBanner(
            @ApiParam(value = "公司uid") @RequestParam(value = "corpUid") String corpUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "门店名称") @RequestParam(value = "storeName") String storeName,
            @ApiParam(value = "员工uid") @RequestParam(value = "staffUid") String staffUid,
            @ApiParam(value = "员工名") @RequestParam(value = "staffName") String staffName
    ) {
        List<WebImage> list = webImageService.getByTypeIdAndEnabled(3, 1);

        return R.ok(list);
    }


    @ApiOperation(value = "获取员工可使用的代金券")
    @PostMapping(value = "/getStaffCoupons")
    public R<Object> getStaffCoupons(
            @ApiParam(value = "公司uid") @RequestParam(value = "corpUid") String corpUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "门店名称") @RequestParam(value = "storeName") String storeName,
            @ApiParam(value = "员工uid") @RequestParam(value = "staffUid") String staffUid,
            @ApiParam(value = "员工名") @RequestParam(value = "staffName") String staffName
    ) {
        List<CouponStaff> list = couponStaffService.staffUseCouponList(storeUid, staffUid);
        return R.ok(list);
    }

}